/**
 * 使用reachBottom 上拉刷新列表页
 * 
 * */
const listMixins = {
	data() {
		return {
			list: [1, 2],
			page: 1,
			limit: 10,
			loading: true,
			loadStatus: 'more',
			noever: false
		};
	},
	/**
	 * 上拉加载
	 * */
	onReachBottom() {
		const that = this;
		if (that.loadStatus !== 'more') return;
		that.page++;
		that.getList();
	},
	/**
	 * onLoad,	重新定义getList
	 * */
	onLoad() {
		const that = this;
		function overwriteGetList() {
			let oldGetList = that.getList;
			that.getList = () => {
				that.loadStatus = 'loading';
				oldGetList((res) => {
					let data = res.data.records;
					that.list = that.page === 1 ? data : that.list.concat(data);
					that.loadStatus = data.length < that.limit ? 'noMore' : 'more';
					that.noever = (that.list.length === 0);
				});
			};
			overwriteGetList = ()=>{};
		}
		overwriteGetList();
	}
};

export default listMixins;
